package com.lan;


import java.io.IOException;
import java.io.InputStream;

public class Script {

    public static void main(String[] args) throws Exception {
//        String[] arr = new String[]{"00.jsl", "01.jsl", "21.jsl", "22.jsl", "23.jsl","23_1.jsl","25_0.jsl","25_2.jsl","25_3.jsl","25_4.jsl","25_5.jsl"};
//        String[] arr = new String[]{"25_6.jsl", "25_7.jsl", "25_7.jsl", "25_9.jsl", "25_10.jsl","25_11.jsl"};
//        String[] arr = new String[]{"26_01.jsl","26_02.jsl","26_03.jsl","26_04.jsl","26_05.jsl","26_06.jsl","26_07.jsl"};

//        String[] arr = new String[]{"26_09.jsl","26_10.jsl","26_11.jsl"};

//        String[] arr = new String[]{"26_12.jsl"};

        String[] arr = new String[]{"30_0.jsl"};
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
            InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("base/" + arr[i]);
            String script = read(is);
            ScriptCompiler compiler = new ScriptCompiler();
            compiler.compile(script);
        }
    }

    private static String read(InputStream is) throws IOException {
        StringBuilder sb = new StringBuilder();
        byte buffer[] = new byte[1024];
        int n = -1;
        while ((n = is.read(buffer, 0, 1024)) != -1) {
            sb.append(new String(buffer, 0, n, "UTF-8"));
        }
        return sb.toString();
    }

}
